# $Id$
# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=traceback2
pkgbase=mingw-w64-python-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-python2-${_realname}"
pkgver=1.4.0
pkgrel=4
pkgdesc='Backports of the traceback module (mingw-w64)'
arch=('any')
url='https://github.com/testing-cabal/traceback2'
license=('PSF')
depends=("${MINGW_PACKAGE_PREFIX}-python2-linecache2" 
         "${MINGW_PACKAGE_PREFIX}-python2-six")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools" 
             "${MINGW_PACKAGE_PREFIX}-python2-pbr"
             "${MINGW_PACKAGE_PREFIX}-python2-contextlib2")
source=("https://pypi.python.org/packages/source/t/${_realname#*-}/${_realname#*-}-${pkgver}.tar.gz")
sha512sums=('84c7fc291c8f2d4cee10441cdef1820aa453e631dfa91ed58e40fc205e97a9dd2101388d5689e4fdf10edfbf06bdb5b895d1635ae7218ba0c9b697d3f95f9342')

#source=("${_realname}-$pkgver.tar.gz"::"https://github.com/testing-cabal/traceback2/archive/$pkgver.tar.gz")
#sha256sums=('3bce822d6b97a06982938d477c5d39460e4fb7704b412e366b45371373980903')

# Helper macros to help make tasks easier #
apply_patch_with_msg() {
  for _patch in "$@"
  do
    msg2 "Applying $_patch"
    patch -Nbp1 -i "${srcdir}/$_patch"
  done
}

del_file_exists() {
  for _fname in "$@"
  do
    if [ -f $_fname ]; then
      rm -rf $_fname
    fi
  done
}
# =========================================== #

prepare() {
  cd "${srcdir}"
  rm -rf python2-build-${CARCH} | true
  cp -r ${_realname#*-}-${pkgver} "python2-build-${CARCH}"
  export PBR_VERSION=$pkgver
}


# Note that build() is sometimes skipped because it's done in 
# the packages setup.py install for simplicity if you can do so.
# but sometimes, you want to do a check before install which would
# also trigger the build.
build() {
  msg "Python 2 build for ${CARCH}"  
  cd "${srcdir}/python2-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python2 setup.py build
}

#check() {
#  msg "Python 2 test for ${CARCH}"  
#  cd "${srcdir}/python2-build-${CARCH}"
#  ${MINGW_PREFIX}/bin/python2 -m subunit.run discover
#}

package() {
  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix="${MINGW_PREFIX}" \
     --root="${pkgdir}" --optimize=1 --skip-build
}

# vim: ts=2 sw=2 et:
